<html>
<head><meta charset="utf-8"><title>inline consts · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html">inline consts</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221366798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221366798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221366798">(Jan 01 2021 at 20:12)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="120791">@RalfJ</span> <a href="https://github.com/rust-lang/rust/issues/76001#issuecomment-753371660">https://github.com/rust-lang/rust/issues/76001#issuecomment-753371660</a></p>



<a name="221366876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221366876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221366876">(Jan 01 2021 at 20:14)</a>:</h4>
<p>i feel like there are two incompatible ideas for const blocks here which I would like to <del>unify</del><em>discuss</em></p>



<a name="221366911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221366911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221366911">(Jan 01 2021 at 20:15)</a>:</h4>
<p>the current implementation treats inline consts like other anonymous constants, e.g. array lengths, with some smaller differences</p>



<a name="221366955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221366955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221366955">(Jan 01 2021 at 20:16)</a>:</h4>
<p>this means that we currently require them to be const evaluatable during typeck</p>



<a name="221366979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221366979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221366979">(Jan 01 2021 at 20:16)</a>:</h4>
<p>an example here is:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(inline_const)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=edcc772fcb11a5f4e26a1cc66320c161">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=edcc772fcb11a5f4e26a1cc66320c161</a></p>



<a name="221366994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221366994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221366994">(Jan 01 2021 at 20:17)</a>:</h4>
<p>once <code>feature(const_evaluatable_checked)</code> gets stabilized, we pretty much get complex expressions in inline consts for free</p>



<a name="221367004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367004">(Jan 01 2021 at 20:17)</a>:</h4>
<p>but just as we were able to stabilize <code>min_const_generics</code> without <code>const_evaluatable_checked</code>, we can stabilize inline consts in the same way</p>



<a name="221367074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367074">(Jan 01 2021 at 20:19)</a>:</h4>
<p>this is the idea that I had in mind. This is fundamentally incompatible with treating inline consts like promoteds as we have to be able to access their mir during typeck for this. That isn't possible if we typeck them as ordinary exprs in their surrounding context</p>



<a name="221367142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367142">(Jan 01 2021 at 20:20)</a>:</h4>
<p>now implementing the remaining issues here isn't too much effort except for one small(ish) annoyance</p>



<a name="221367157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367157">(Jan 01 2021 at 20:21)</a>:</h4>
<p>we cannot have the content of const blocks influence the type inference of the containing body</p>



<a name="221367224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367224">(Jan 01 2021 at 20:23)</a>:</h4>
<p>so the following would fail to compile</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">ty_eq</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span>: <span class="nc">T</span><span class="p">,</span><span class="w"> </span><span class="n">_</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">7</span><span class="k">u32</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">   </span><span class="n">ty_eq</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="221367271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367271">(Jan 01 2021 at 20:24)</a>:</h4>
<p>because we can't look into the const block while typechecking main and therefore assume <code>x</code> to be of type <code>i32</code> here.</p>



<a name="221367278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367278">(Jan 01 2021 at 20:25)</a>:</h4>
<p>using your approach based on promotion would allow this however</p>



<a name="221367413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367413">(Jan 01 2021 at 20:29)</a>:</h4>
<p>/me reading the RFC again to check if anyone thought of this before or if those two concepts were thrown together</p>



<a name="221367487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367487">(Jan 01 2021 at 20:31)</a>:</h4>
<p>so the rfc expects us to use generic params in inline consts in the future and doesn't go into any details regarding type inference</p>



<a name="221367763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367763">(Jan 01 2021 at 20:38)</a>:</h4>
<blockquote>
<p>AnonConst are used to represent constant expressions, so they are used for array lengths and associated constants.</p>
</blockquote>
<p>Those are two very different beasts from my perspective, so I am not sure how to make sense of this. associated consts are items; array lengths are not. or so I thought.</p>



<a name="221367788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367788">(Jan 01 2021 at 20:39)</a>:</h4>
<p><code>const ASSOC: ty = expr;</code> is <del>internally represented</del><em>can be thought of</em> as <code>const ASSOC: ty = &lt;anon const&gt;;</code></p>



<a name="221367802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367802">(Jan 01 2021 at 20:39)</a>:</h4>
<p>so the anon const is the actual expression of an associated const, does that make more sense?</p>



<a name="221367858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367858">(Jan 01 2021 at 20:40)</a>:</h4>
<p>hm... not sure what exactly this means. but it doesn't matter all that much to me I guess as I am working on the MIR level.</p>



<a name="221367864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367864">(Jan 01 2021 at 20:40)</a>:</h4>
<p>I care very little for the layers that come before that ;)</p>



<a name="221367869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367869">(Jan 01 2021 at 20:40)</a>:</h4>
<p><span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="221367907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367907">(Jan 01 2021 at 20:41)</a>:</h4>
<p>hm, so to sum up the above rambling, I do not think using your idea and employing promotion for this is the right choice</p>



<a name="221367956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367956">(Jan 01 2021 at 20:42)</a>:</h4>
<p>hm... I think requiring up-front proof that all inline consts will succeed to evaluate is waaay overdoing it^^</p>



<a name="221367960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367960">(Jan 01 2021 at 20:42)</a>:</h4>
<p>there is a trade-off here as "my" approach restricts type inference which might be annoying in - i expect rare - cases</p>



<a name="221367968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367968">(Jan 01 2021 at 20:42)</a>:</h4>
<p>yeah but I am not very concerned about that</p>



<a name="221367978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367978">(Jan 01 2021 at 20:43)</a>:</h4>
<p>my concern is more around all the other things people want to do with consts, and it being utterly infeasible to prove upfront that there wont be a panic</p>



<a name="221367980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367980">(Jan 01 2021 at 20:43)</a>:</h4>
<p>yeah, but the same issue is also true for array lengths and stuff</p>



<a name="221367983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367983">(Jan 01 2021 at 20:43)</a>:</h4>
<p>so i want to be consistent here</p>



<a name="221367985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367985">(Jan 01 2021 at 20:43)</a>:</h4>
<p>we might not end up requiring const wf bounds everywhere</p>



<a name="221367987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221367987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221367987">(Jan 01 2021 at 20:43)</a>:</h4>
<p>in particular I want <code>const</code> blocks to cover this usecase: <a href="https://github.com/rodrimati1992/abi_stable_crates/issues/46">https://github.com/rodrimati1992/abi_stable_crates/issues/46</a></p>



<a name="221368026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368026">(Jan 01 2021 at 20:44)</a>:</h4>
<p>and I very much doubt that that is possible with "your" approach</p>



<a name="221368035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368035">(Jan 01 2021 at 20:44)</a>:</h4>
<p>but also, covering that usecase somehow is pretty much a must if we want to ever stop promoting <code>const fn</code> calls in <code>const</code>/<code>static</code> initializers</p>



<a name="221368050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368050">(Jan 01 2021 at 20:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221367980">said</a>:</p>
<blockquote>
<p>yeah, but the same issue is also true for array lengths and stuff</p>
</blockquote>
<p>dunno, array lengths "feel" different for me because they are "type system level stuff". which promtoeds and (in my head) inline consts are not. so I can see some justification to treating them differently.</p>



<a name="221368066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368066">(Jan 01 2021 at 20:45)</a>:</h4>
<p>this feels similar to dependent type theories that do permit diverging expressions, but ensure they do not arise in the type level</p>



<a name="221368114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368114">(Jan 01 2021 at 20:46)</a>:</h4>
<p>(I'm just doing some brain dumping here; I haven't though much about <code>const_evaluatable_checked</code> before so I am certainly not familiar with the fine points)</p>



<a name="221368285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368285">(Jan 01 2021 at 20:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221368050">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221367980">said</a>:</p>
<blockquote>
<p>yeah, but the same issue is also true for array lengths and stuff</p>
</blockquote>
<p>dunno, array lengths "feel" different for me because they are "type system level stuff". which promtoeds and (in my head) inline consts are not. so I can see some justification to treating them differently.</p>
</blockquote>
<p>so can I <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="221368546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368546">(Jan 01 2021 at 20:57)</a>:</h4>
<p>we can ofc use the current approach and just not emit a <code>ConstEvalutable</code> predicate for inline consts</p>



<a name="221368555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368555">(Jan 01 2021 at 20:57)</a>:</h4>
<p>which would probably be fine for me though I do feel kind of uncomfortable about this</p>



<a name="221368607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368607">(Jan 01 2021 at 20:58)</a>:</h4>
<p>or even just make const evaluatable checked a lint for inline and assoc consts</p>



<a name="221368664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368664">(Jan 01 2021 at 21:00)</a>:</h4>
<p>ping <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="221368701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368701">(Jan 01 2021 at 21:01)</a>:</h4>
<p>ah well, will go ahead and fix the remaining bugs for ìnline consts in the next few weeks and then we can decide where to go [while using <code>AnonConst</code>s]</p>



<a name="221368745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221368745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221368745">(Jan 01 2021 at 21:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221367224">said</a>:</p>
<blockquote>
<p>so the following would fail to compile</p>
<p><div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">ty_eq</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span>: <span class="nc">T</span><span class="p">,</span><span class="w"> </span><span class="n">_</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">7</span><span class="k">u32</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">   </span><span class="n">ty_eq</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div><br>
</p>
</blockquote>
<p>as long as no one thinks that this restriction is a big issue</p>



<a name="221372061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372061">(Jan 01 2021 at 22:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221367987">said</a>:</p>
<blockquote>
<p>in particular I want <code>const</code> blocks to cover this usecase: <a href="https://github.com/rodrimati1992/abi_stable_crates/issues/46">https://github.com/rodrimati1992/abi_stable_crates/issues/46</a></p>
</blockquote>
<p>I don't see how that is problematic, considering that all these promotions are in constant items and not in <code>const fn</code>, so there is no <code>const_evaluatable_checked</code> necessary.</p>



<a name="221372078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372078">(Jan 01 2021 at 22:27)</a>:</h4>
<p>Here's the relevant tracking issue: <a href="https://github.com/rust-lang/rust/issues/76560">https://github.com/rust-lang/rust/issues/76560</a></p>



<a name="221372658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372658">(Jan 01 2021 at 22:42)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> i originally wanted to require inline consts to also have const evaluatable bounds, which would mean that <a href="https://github.com/rodrimati1992/abi_stable_crates/issues/46">https://github.com/rodrimati1992/abi_stable_crates/issues/46</a> won't be easily fixable by using inline consts</p>



<a name="221372679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372679">(Jan 01 2021 at 22:43)</a>:</h4>
<p>I thought these hypothetical inline const usages are themselves within const items</p>



<a name="221372683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372683">(Jan 01 2021 at 22:43)</a>:</h4>
<p>brb reading more source code</p>



<a name="221372748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372748">(Jan 01 2021 at 22:44)</a>:</h4>
<p>yeah they are, but they would still require const wf bounds. we check const wf for arrays used in associated consts</p>



<a name="221372762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372762">(Jan 01 2021 at 22:45)</a>:</h4>
<p>oh... are we talking about associated consts?</p>



<a name="221372780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372780">(Jan 01 2021 at 22:45)</a>:</h4>
<p><a href="https://github.com/rodrimati1992/abi_stable_crates/issues/46">https://github.com/rodrimati1992/abi_stable_crates/issues/46</a> promotes a generic const fn inside of an associated const</p>



<a name="221372788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372788">(Jan 01 2021 at 22:45)</a>:</h4>
<p>(inside of a macro, but that doesn't matter <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> )</p>



<a name="221372836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372836">(Jan 01 2021 at 22:46)</a>:</h4>
<p>and we want to replace that generic const fn call with <code>const { const_fn_call() }</code></p>



<a name="221372850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372850">(Jan 01 2021 at 22:46)</a>:</h4>
<p>i initially wanted to require <code>WF(const_fn_call())</code> for this</p>



<a name="221372857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372857">(Jan 01 2021 at 22:46)</a>:</h4>
<p>but is it in a <em>generic</em> impl of an associated const?</p>



<a name="221372858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372858">(Jan 01 2021 at 22:46)</a>:</h4>
<p>I see things like <a href="https://github.com/rodrimati1992/abi_stable_crates/blob/6375dd95e0df0808b0eedf2aaa2ecb7f971875fd/examples/0_modules_and_interface_types/impl/src/lib.rs#L90">https://github.com/rodrimati1992/abi_stable_crates/blob/6375dd95e0df0808b0eedf2aaa2ecb7f971875fd/examples/0_modules_and_interface_types/impl/src/lib.rs#L90</a></p>



<a name="221372871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372871">(Jan 01 2021 at 22:47)</a>:</h4>
<p>i think so. If the type deriving <code>StableAbi</code> is generic</p>



<a name="221372876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372876">(Jan 01 2021 at 22:47)</a>:</h4>
<p>ah, I found <a href="https://github.com/rodrimati1992/abi_stable_crates/blob/6375dd95e0df0808b0eedf2aaa2ecb7f971875fd/abi_stable/src/erased_types/dyn_trait/tests.rs#L59">https://github.com/rodrimati1992/abi_stable_crates/blob/6375dd95e0df0808b0eedf2aaa2ecb7f971875fd/abi_stable/src/erased_types/dyn_trait/tests.rs#L59</a></p>



<a name="221372930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372930">(Jan 01 2021 at 22:48)</a>:</h4>
<p>yea ok, ignore my comments above then... this is indeed incompatible</p>



<a name="221372942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221372942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221372942">(Jan 01 2021 at 22:49)</a>:</h4>
<p>well... let's explore some more what other things beyond a breaking change are possible here: <a href="#narrow/stream/213817-t-lang/topic/Promotion.20of.20const.20fn.20calls.20in.20const.2Fstatic.20initializers/near/221372470">https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Promotion.20of.20const.20fn.20calls.20in.20const.2Fstatic.20initializers/near/221372470</a></p>



<a name="221373063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221373063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221373063">(Jan 01 2021 at 22:52)</a>:</h4>
<p>regardless of the outcome of that thread, there is still the question of if <code>const { expr() }</code> should require <code>ConstEvaluatable(expr())</code> or not <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="221373819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221373819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221373819">(Jan 01 2021 at 23:13)</a>:</h4>
<p>well... we could <em>definitely</em> skip it if implicit promotion accepts the entire body of the <code>AnonConst</code></p>



<a name="221373890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221373890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221373890">(Jan 01 2021 at 23:15)</a>:</h4>
<p>we'll still end up with post monomorphization errors if the constant doesn't eval</p>



<a name="221373947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221373947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221373947">(Jan 01 2021 at 23:16)</a>:</h4>
<p>I get that the constants in array lengths are a bit different wrt evaluatability, but that fundamental point still stands</p>



<a name="221398199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221398199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221398199">(Jan 02 2021 at 12:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221373819">said</a>:</p>
<blockquote>
<p>well... we could <em>definitely</em> skip it if implicit promotion accepts the entire body of the <code>AnonConst</code></p>
</blockquote>
<p>it won't though. the entire point is to not implicitly promote function calls ever since they can fail.</p>



<a name="221398249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221398249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221398249">(Jan 02 2021 at 12:36)</a>:</h4>
<p>i think the idea would be to allow generic anonymous constants if they would be accepted by promotion</p>



<a name="221398252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221398252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221398252">(Jan 02 2021 at 12:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221373890">said</a>:</p>
<blockquote>
<p>we'll still end up with post monomorphization errors if the constant doesn't eval</p>
</blockquote>
<p>yeah, just like we already have post-mono errors now with associated consts.<br>
it may just be the case that preventing post-mono errors at all cost is more painful than the errors. I'm not saying it is -- I haven't dug into the issue -- but I sometimes get that feeling.</p>



<a name="221398269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221398269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221398269">(Jan 02 2021 at 12:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221398249">said</a>:</p>
<blockquote>
<p>i think the idea would be to allow generic anonymous constants if they would be accepted by promotion</p>
</blockquote>
<p>yeah but what I am saying is, the ones in AbiStable will <em>not</em> be accepted by promotion any more. that's the entire point, to stop promoting these things.</p>



<a name="221398322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221398322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221398322">(Jan 02 2021 at 12:38)</a>:</h4>
<p>hmm, so my understanding was that we would have a check similar to the old(current) promotion rules</p>



<a name="221398328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221398328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221398328">(Jan 02 2021 at 12:38)</a>:</h4>
<p>but that seems far to lenient to me now that i think about it</p>



<a name="221398476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221398476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221398476">(Jan 02 2021 at 12:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221398322">said</a>:</p>
<blockquote>
<p>hmm, so my understanding was that we would have a check similar to the old(current) promotion rules</p>
</blockquote>
<p>which of them?^^ they keep changing, and we have implicit and explicit rules and then some special exceptions in const/static initializers</p>



<a name="221407633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407633">(Jan 02 2021 at 17:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/221367074">said</a>:</p>
<blockquote>
<p>this is the idea that I had in mind. This is fundamentally incompatible with treating inline consts like promoteds as we have to be able to access their mir during typeck for this. That isn't possible if we typeck them as ordinary exprs in their surrounding context</p>
</blockquote>
<p><span class="user-mention" data-user-id="124288">@oli</span> regarding <a href="https://github.com/rust-lang/rust/issues/76001#issuecomment-753497465">https://github.com/rust-lang/rust/issues/76001#issuecomment-753497465</a> and building mir for consts together with their containing body. For anything we want to look at during typeck, e.g. for <code>ConstEvaluatable</code> bounds or anything inside of types that isn't possible</p>



<a name="221407652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407652">(Jan 02 2021 at 17:05)</a>:</h4>
<p><em>the length of repeat expressions does end up in its type</em></p>



<a name="221407676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407676">(Jan 02 2021 at 17:05)</a>:</h4>
<p>oh right... we still have some typeck stuff on HIR</p>



<a name="221407744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407744">(Jan 02 2021 at 17:06)</a>:</h4>
<p>why do we even typecheck mir again?</p>



<a name="221407746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407746">(Jan 02 2021 at 17:06)</a>:</h4>
<p>I forget</p>



<a name="221407747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407747">(Jan 02 2021 at 17:07)</a>:</h4>
<p>is that only a safety net or am i missing somethign</p>



<a name="221407749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407749">(Jan 02 2021 at 17:07)</a>:</h4>
<p>some checks are easier?</p>



<a name="221407755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407755">(Jan 02 2021 at 17:07)</a>:</h4>
<p>like purely failing checks, none that affect resolution or inference</p>



<a name="221407789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407789">(Jan 02 2021 at 17:08)</a>:</h4>
<p>maybe <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> i guess i will make a note to look into that <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="221407797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407797">(Jan 02 2021 at 17:08)</a>:</h4>
<p>I'm not sure if we could have a typeck fully in MIR, I haven't really looked into the topic in the last year</p>



<a name="221407812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407812">(Jan 02 2021 at 17:08)</a>:</h4>
<p>me neither, i only know that we do have some kind of typeck using mir</p>



<a name="221407829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221407829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221407829">(Jan 02 2021 at 17:09)</a>:</h4>
<p>I thought mir typeck collects constraints for mir borrowck to resolve.</p>



<a name="221590916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221590916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221590916">(Jan 04 2021 at 22:37)</a>:</h4>
<p>hold up... we only need the body of inline consts for <code>const_evaluatable_checked</code> in order to <em>error</em> if it's not in the signature. This can be done <em>after</em> building the MIR, there is no need to error before building the MIR, right?</p>



<a name="221591039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221591039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221591039">(Jan 04 2021 at 22:38)</a>:</h4>
<p>Inline consts do not actually affect typeck beyond causing errors if there's no entry for them in the where bounds</p>



<a name="221591096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221591096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221591096">(Jan 04 2021 at 22:39)</a>:</h4>
<p>If that were possible, we could avoid the entire situation, keep the inline consts as part of the HIR body and autogenerate promoteds for them during mir building.</p>



<a name="221591202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/221591202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#221591202">(Jan 04 2021 at 22:40)</a>:</h4>
<p>then mir typeck (or whatever) can check all these inline-const-promoteds against the signature of the owning body</p>



<a name="223039204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223039204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223039204">(Jan 17 2021 at 11:52)</a>:</h4>
<p>^ still thinking about this</p>



<a name="223039246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223039246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223039246">(Jan 17 2021 at 11:52)</a>:</h4>
<p>i am kinda uncomfortable with your idea but not sure whether it would work</p>



<a name="223043087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223043087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223043087">(Jan 17 2021 at 13:36)</a>:</h4>
<p>alternatively... could we handle inline const bodies like we handle closure bodies?</p>



<a name="223043095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223043095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223043095">(Jan 17 2021 at 13:37)</a>:</h4>
<p>I am not too happy with my idea either for the record</p>



<a name="223043280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223043280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223043280">(Jan 17 2021 at 13:42)</a>:</h4>
<p>not if we want to check <code>ConstEvaluatable</code> for them during typeck</p>



<a name="223043284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223043284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223043284">(Jan 17 2021 at 13:42)</a>:</h4>
<p>that was my original idea as well</p>



<a name="223043285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223043285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223043285">(Jan 17 2021 at 13:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/inline.20consts/near/223043087">said</a>:</p>
<blockquote>
<p>alternatively... could we handle inline const bodies like we handle closure bodies?</p>
</blockquote>
<p>that sounds good, though I don't know the consequences. I assume <code>async</code> blocks also use that machinery?</p>



<a name="223772888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223772888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223772888">(Jan 23 2021 at 20:11)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> i am currently writing down my knowledge about the big const generics issues we want to solve in <a href="https://hackmd.io/9LIywezOQj-h5HX8vvEnSw">https://hackmd.io/9LIywezOQj-h5HX8vvEnSw</a></p>
<p>Taking oli's approach should work. checking that they are const evaluatable doesn't actually have to happen during typeck so we can move that into a separate query.</p>



<a name="223831099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/inline%20consts/near/223831099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/inline.20consts.html#223831099">(Jan 24 2021 at 19:36)</a>:</h4>
<p>I'm currently on vacations but will be back in 1 week</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>